﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FluentValidation;

using ERPStore.Validators;

namespace ERPStore.ModelValidators
{
    public class AddressValidator : AbstractValidator<Models.Address>
    {
        public AddressValidator()
        {
            RuleFor(m => m.RecipientName)
				.NotNullOrTrimmedEmpty()
				.WithMessage("Vous devez indiquer un nom");

            RuleFor(m => m.Street)
				.NotNullOrTrimmedEmpty()
				.WithMessage("Vous devez indiquer une rue ou un lieu dit");

            RuleFor(m => m.ZipCode)
				.NotNullOrTrimmedEmpty()
				.WithMessage("Vous devez indiquer un code postal");

			RuleFor(m => m.ZipCode)
				.ZipCode(m => m.Country)
				.WithMessage("Code postal invalide");

            RuleFor(m => m.City)
				.NotNullOrTrimmedEmpty()
				.WithMessage("Vous devez indiquer une ville");

        }
    }
}
